package com.ky.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ky.common.vo.R;
import com.ky.user.entity.LearnMoney;
import com.ky.user.mapper.LearnMoneyMapper;
import com.ky.user.service.LearnMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hmt
 * @since 2024-06-24
 */
@Service
public class LearnMoneyServiceImpl extends ServiceImpl<LearnMoneyMapper, LearnMoney> implements LearnMoneyService {
    @Autowired
    LearnMoneyMapper learnMoneyMapper;
    @Override
    public R findALLLearnMoney(Integer id) {
        QueryWrapper<LearnMoney> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("SUM(learn_money) as learnMoney").eq("user_id", id);
        Map<String, Object> result = learnMoneyMapper.selectMaps(queryWrapper).get(0);
        return R.ok(result.get("learnMoney").toString());
    }
}
